package com.cwl.pattern.备忘录模式;

/**
 * @program: pattern
 * @description: 测试用例
 * @author: ChenWenLong
 * @create: 2019-07-10 12:50
 **/
public class MementoPattern {

    public static void main(String[] args) {
        Originator or=new Originator();
        Caretaker cr=new Caretaker();
        or.setState("S0");
        System.out.println("初始状态:"+or.getState());
        cr.setMemento(or.createMemento()); //保存状态
        or.setState("S1");
        System.out.println("新的状态:"+or.getState());
        or.restoreMemento(cr.getMemento()); //恢复状态
        System.out.println("恢复状态:"+or.getState());
    }
}
